//
//  KDSubscripRequestTool.m
//  WangJingApp
//
//  Created by 魏强 on 17/2/23.
//  Copyright © 2017年 KDTech. All rights reserved.
//

#import "KDSubscripRequestTool.h"
#import "KDBaseTool.h"
#import "KDAddCommentParam.h"
#import "KDGetCommentListParam.h"
#import "KDGetSubscribedResult.h"
#import "KDGetSubscribeListResult.h"
#import "KDGetCommentListResult.h"
#import "KDAllSubscribeResult.h"
#import "KDSubscribeDetailResult.h"
@implementation KDSubscripRequestTool
/**  获取对应订阅主题下的列表 */
+ (void)getSubscribeListWithParam:(KDSubscribeListParam *)param success:(void (^)(KDGetSubscribeListResult *responseObejct))success failure:(void(^)(NSError *error))failure{
    NSString *url = [NSString stringWithFormat:@"%@%@",ServerActionAddr,param.method];
    [KDBaseTool get:url param:param resultClass:[KDGetSubscribeListResult class] success:success failure:failure];
}
/**  获取已订阅的主题 */
+ (void)getSubscribedModelWithParam:(KDBaseParam *)param success:(void (^)(KDGetSubscribedResult *responseObejct))success failure:(void(^)(NSError *error))failure{
    NSString *url = [NSString stringWithFormat:@"%@%@",ServerActionAddr,param.method];
    [KDBaseTool get:url param:param resultClass:[KDGetSubscribedResult class] success:success failure:failure];
}
/**  获取所有已订阅未订阅的主题 */
+ (void)getAllSubscribeModelWithParam:(KDBaseParam *)param success:(void (^)(KDAllSubscribeResult *responseObejct))success failure:(void(^)(NSError *error))failure{
    NSString *url = [NSString stringWithFormat:@"%@%@",ServerActionAddr,param.method];
    [KDBaseTool get:url param:param resultClass:[KDAllSubscribeResult class] success:success failure:failure];
}

/**
 *  更新订阅类型
 *
 *  @param param   一个包含了所有需要订阅的类型的数组
 */
+ (void)updateAllSubscribeModelWithParam:(id)param success:(void (^)(KDGetSubscribedResult *responseObejct))success failure:(void(^)(NSError *error))failure{
    NSString *url = [NSString stringWithFormat:@"%@%@",ServerActionAddr,@"earlyWaringSetting/updateEarlywaringPushUserSubscribe"];
    [KDBaseTool post:url bodyJson:param resultClass:[KDGetSubscribedResult class] success:success failure:failure];
}


+ (void)addCommentWithParam:(KDAddCommentParam *)param success:(void (^)(KDBaseResult *responseObejct))success failure:(void(^)(NSError *error))failure{
    NSString *url = [NSString stringWithFormat:@"%@%@",ServerActionAddr,param.method];
    [KDBaseTool post:url param:param resultClass:[KDBaseResult class] success:success failure:failure];
}

+ (void)getCommentListWithparam:(KDGetCommentListParam *)param success:(void (^)(KDGetCommentListResult *responseObejct))success failure:(void(^)(NSError *error))failure{
    NSString *url = [NSString stringWithFormat:@"%@%@",ServerActionAddr,param.method];
    [KDBaseTool post:url param:param resultClass:[KDGetCommentListResult class] success:success failure:failure];
}

+(void)getSubscribeDetailWithparam:(KDSubscribeListParam*)param success:(void (^)(KDSubscribeDetailResult *))success failure:(void (^)(NSError *))failure{
    NSString *url = [NSString stringWithFormat:@"%@%@",ServerActionAddr,@"news/getNews"];
    [KDBaseTool post:url param:param resultClass:[KDSubscribeDetailResult class] success:success failure:failure];
}
@end
